
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

typedef struct {
    float y;
    float z;
    float u;
}  point;
bool comp(const point &, const point &);

int main()
{
    vector<int>::iterator m;
    const float M = 1.9635;
    point a;
    list<point> points;
    // list<point> points;
    // ofstream file_in("myfile.txt")
    FILE* fo = fopen("myfile.txt", "r");
    while(fscanf(fo, "%f%f%f", &a.y, &a.z, &a.u) == 3){
        points.push_back(a);
        // cout << points.size() <<"\n";
    }
    fclose(fo);
    // auto num = points.size();
    for(auto i = points.begin(); i != points.end();){
        if(abs(i->z - M) < 0.00001) i = points.erase(i);
        else ++i;
    }
    points.sort(comp);
    cout << points.size() << endl;
    FILE* fout = fopen("line.txt", "w");
    fprintf(fout, "variables = \"y\", \"u/U_inf\" \n");
    int num = points.size();
    fprintf(fout, "zone\t I = %d\n", num);
    for(auto it= points.begin(); it != points.end(); ++it){
        fprintf(fout, "%f\t%f\n", it->y, it->u);
    }
    fclose(fout);
    return 0;
}
bool comp(const point &p1, const point &p2){
    return p1.y < p2.y;
}
